#pragma once
#include "FileHandler.h"
#include "LinkedList.h"
namespace QSDHANDLER
{
	class Object
	{
	public:
		Object(){}
		~Object(){}
		virtual void Load( char* a_FilePath ){}
		virtual void Save( char* a_FilePath ){}
	};
	
	class Condition : public Object
	{
	public:
		void Load( FileHandler* a_File );
		void Save( FileHandler* a_File );
	private:
		int m_Length;
		int m_Command;

	};

	class Action : public Object
	{
	public:
		void Load( FileHandler* a_File );
		void Save( FileHandler* a_File );
	private:
		int m_Length;
		int m_Command;

	};

	class Record
	{
	public:
		Record() { m_Actions = new LinkedList< Action >(); m_Conditions = new LinkedList< Condition >();}
		~Record();
		void Load( FileHandler* a_File );
		void Save( FileHandler* a_File );
	private:
		unsigned char* m_CheckNext;
		int m_ConditionCount;
		int m_ActionCount;
		char* m_RecordName;
		LinkedList< Condition >* m_Conditions;
		Iterator< Condition >* m_ConditionsIt;
		LinkedList< Action >*  m_Actions;
		Iterator< Action >* m_ActionsIt;
	};

	class Block
	{
	public:
		Block() { m_Records = new LinkedList< Record >(); }
		~Block();
		void Load( FileHandler* a_File );
		void Save( FileHandler* a_File );
	private:
		int m_RecordCount;
		char* m_BlockName;
		LinkedList< Record >* m_Records;
		Iterator< Record >* m_RecordsIt;
	};
	
	class QSD
	{
	public:
		QSD();
		~QSD();

		void Load( char* a_FilePath );
		void Save( char* a_FilePath );

	private:
		FileHandler* m_File;

		int m_FileVersion;
		int m_BlockCount;
		char* m_Name;

		LinkedList< Block >* m_Blocks;
		Iterator< Block >* m_BlocksIt;

	};

}
